package com.qk.domain.activity;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

/**
 * @Author: chouh
 * @DateTime: 2025/10/13 1:10
 * @Description:
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ActivityDO {

    private Integer id;

    private Integer channel;

    private String name;

    private LocalDateTime startTime;

    private LocalDateTime endTime;

    private String description;

    private Integer type;

    private Double discount;

    private Integer voucher;

    private LocalDateTime createTime;

    private LocalDateTime updateTime;

    private Integer status;

    //活动状态 1.未开始 2.进行中 3.已结束
    public Integer getStatus() {
        LocalDateTime now = LocalDateTime.now();
        if (now.isBefore(this.startTime)) {
            return 1; // 未开始
        } else if (now.isAfter(this.endTime)) {
            return 3; // 已结束
        } else {
            return 2; // 进行中
        }
    }
}
